package com.tanhua.admin.controller;

import com.tanhua.admin.service.ManageService;
import com.tanhua.model.pojo.UserInfo;
import com.tanhua.model.vo.MovementsVo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.VideoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    /**
     * 查询用户列表
     */
    @GetMapping("/users")
    public ResponseEntity findByPage(@RequestParam(defaultValue = "page", required = false) Integer page,
                                     @RequestParam(defaultValue = "pagesize", required = false) Integer pagesize,
                                     Long id, String nickname, String city) {

        PageResult<UserInfo> pageResult = manageService.findByPage(page, pagesize, id, nickname, city);

        return ResponseEntity.ok(pageResult);
    }


    /**
     * 查看用户的详情信息
     */
    @GetMapping("/users/{userId}")
    public ResponseEntity findByUserId(@PathVariable Long userId) {
        UserInfo userInfo = manageService.findByUserId(userId);

        return ResponseEntity.ok(userInfo);
    }

    /**
     * 查看用户的视频记录
     */
    @GetMapping("/videos")
    public ResponseEntity findByPageVideo(@RequestParam(defaultValue = "1", required = false) Integer page,
                                          @RequestParam(defaultValue = "10", required = false) Integer pagesize,
                                          Long uid) {

        PageResult<VideoVo> pageResult = manageService.findByPageVideo(page, pagesize, uid);

        return ResponseEntity.ok(pageResult);

    }

    /**
     * 用户动态数据
     */
    @GetMapping("/messages")
    public ResponseEntity findByPageMovement(@RequestParam(defaultValue = "1", required = false) Integer page,
                                             @RequestParam(defaultValue = "10", required = false) Integer pagesize,
                                             Long uid,Integer state) {

        PageResult<MovementsVo> pageResult = manageService.findByPageMovement(page, pagesize, uid, state);

        return ResponseEntity.ok(pageResult);

    }

}
